package Presentation.GraphicUI;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MovieSearchPanel extends MovieSystemPanel
{

	public MovieSearchPanel(MainScreen mainScreen)
	{
		super(mainScreen);

		final ButtonGroup group = new ButtonGroup();
		final JPanel a = this;
		final JPanel xj = new JPanel();
		JButton button1 = new JButton("Search");
		final JTextField tf = new JTextField(15);
		JLabel l = new JLabel("Movie name: ");
		xj.add(l);
		xj.add(tf);
		xj.add(button1);
		setVisible(true);

		add(xj);

		button1.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
			    String[] buttonLabels = m_controller.searchMovie(tf.getText(),"EXACT_NAME",0);
				JCheckBox option;
                for (String buttonLabel : buttonLabels) {
                    option = new JCheckBox(buttonLabel);
                    group.add(option);
                    a.add(option);
                }
                xj.revalidate();
				a.revalidate();
				m_mainScreen.repaint();
			}
		});
		
		
		
	
	}
}
